home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 1.iso / desktop / dviwin29.zip / GENPK.BAT < prev    next >
DOS Batch File  |  1994-12-01  |  8KB  |  237 lines

  1. @echo off
  2. rem    This is a sample batch file to run metafont, convert the GF file to
  3. rem    the PK format and store the PK font in the appropriate directory. It
  4. rem    is meant to be called by dviwin and that's the reason for the absence
  5. rem    of any parameter checking. It also assumes that metafont and gftopk
  6. rem    are operating properly. This sample file attempts to cover as many
  7. rem    devices as possible; you will probably get better and faster results
  8. rem    if you write a smaller and more specialized batch file.
  9. rem
  10. rem    The plain base is a prerequisite: make sure that you generate it by
  11. rem    running inimf on plain.mf, then input the file modes.mf (version 2.1
  12. rem    or later; you can get it from the directory /tex-archive/fonts/modes
  13. rem    at the CTAN hosts: ftp.shsu.edu, ftp.dante.de and ftp.tex.ac.uk; some
  14. rem    modes will not work properly with earlier versions of the modes.mf
  15. rem    file) and finally dump the format file. If you don't know what I am
  16. rem    talking about, please read the documentation that comes with the
  17. rem    metafont program, as well as the Metafont book.
  18. rem
  19. rem    You WILL need to modify the routine to place the PK files in the
  20. rem    proper directory; the current method uses the environment variable
  21. rem    DVIFONTS which is assumed to contain the base directory for the PK
  22. rem    fonts. Any square-pixel fonts are assumed to be stored in the
  23. rem    directories  $(DVIFONTS)\X  where X is the resolution of the font.
  24. rem    Non-square-pixel fonts are assumed to stored in the directories
  25. rem    $(DVIFONTS)\XxY where X is the horizontal resolution and Y is the
  26. rem    vertical resolution.
  27. rem
  28. rem    It is trivial to modify the name of metafont and the base directory;
  29. rem    just select the proper values for the first two statements after
  30. rem    these comments. If you use another directory structure, you need
  31. rem    to modify the next two statements.
  32. rem
  33. rem    You may also need to do more modifications if you have other devices;
  34. rem    this batch file generates fonts for the screen, 300dpi laser and
  35. rem    inkjet printers, 600dpi laserjets, as well as 9-pin and 24-pin dot
  36. rem    matrix printers. If you want to use another device, you will have to
  37. rem    understand the code below and modify it accordingly (maybe you will
  38. rem    want to rewrite the code in a compiled language to improve the speed,
  39. rem    the error handling and avoid all the ugly gotos). If you want to use
  40. rem    a 9-pin dot matrix printer at 120x144dpi or 240x144dpi, or an HP
  41. rem    Deskjet 520 at 600x300dpi, append the following lines to the file
  42. rem    modes.mf and regenerate the plain base.
  43. rem
  44. rem    mode_def epsmed =        % Epson-FX at 240x144dpi
  45. rem        mode_param (pixels_per_inch, 240);
  46. rem        mode_param (aspect_ratio, 144 / pixels_per_inch);
  47. rem        EpsonMXFX_;
  48. rem    enddef;
  49. rem
  50. rem    mode_def epsmedl =        % Lanscape version of epsmed
  51. rem        epsmed_;
  52. rem        landscape;
  53. rem    enddef;
  54. rem
  55. rem    mode_def epswlo =        % Epson-FX at 120x144dpi
  56. rem        mode_param (pixels_per_inch, 120);
  57. rem        mode_param (aspect_ratio, 144 / pixels_per_inch);
  58. rem        EpsonMXFX_;
  59. rem    enddef;
  60. rem
  61. rem    mode_def epswlol =        % Landscape version of epswlo
  62. rem        epswlo_;
  63. rem        landscape;
  64. rem    enddef;
  65. rem
  66. rem    mode_def DJFiveTwenty =        % HP Deskjet at 600x300dpi
  67. rem        mode_param (pixels_per_inch,600);
  68. rem        mode_param (aspect_ratio, 300 / pixels_per_inch);
  69. rem        deskjet_;
  70. rem    enddef;
  71. rem
  72. rem    mode_def DJFiveTwentyl =    % Landscape version of DJFiveTwenty
  73. rem        DJFiveTwenty_;
  74. rem        landscape;
  75. rem    enddef;
  76. rem
  77. rem    If metafont does not recognize any other modes, it will generate
  78. rem    its standard proofing fonts which are HUGE and inappropriate for
  79. rem    your device. In that case, get the file modes.mf from CTAN and
  80. rem    generate the plain base again using the command:
  81. rem        inimf plain;input modes;dump
  82. rem    Then you need to copy plain.bas to the appropriate directory. You
  83. rem    may need to replace "inimf" by "mf -i" for some Metafont versions.
  84. rem
  85. rem    Here are the parameters passed by dviwin:
  86. rem        %1:    fontname    (truncated to 8 chars)
  87. rem        %2:    magstep
  88. rem        %3:    xres        (hor. resolution of font)
  89. rem        %4:    yres            (vert. resolution of font)
  90. rem        %5:    xbase        (base hor. resolution)
  91. rem        %6:    ybase        (base vert. resolution)
  92. rem        %7:    drive        (of current dvi file)
  93. rem        %8:    path        (of current dvi file)
  94. rem        %9:    gf extension    (truncated to 3 chars)
  95. rem
  96. rem    In most cases, you will only need to modify the next four statements:
  97. set MF=mf
  98. set PK_BASE=%DVIFONTS%
  99. set PK_DIR=%PK_BASE%\%3x%4
  100. if %5==%6 set PK_DIR=%PK_BASE%\%3
  101.  
  102. rem    If the font already exists, don't do anything
  103. if exist %PK_DIR%\%1.pk goto GETOUT
  104.  
  105. rem    If you want to switch to the directory of the current dvi file,
  106. rem    uncomment the next two statements. This is useful if you prefer
  107. rem    to keep some mf sources in the dvi file directory instead of the
  108. rem    MFINPUTS directory.
  109. rem %7:
  110. rem cd %8
  111.  
  112. rem    Initialize device and magstep to empty
  113. set PK_DEV=
  114. set PK_MAG=
  115.  
  116. rem    Devices with non-square pixels; we support the following modes:
  117. rem    epsdrft (9-pin 120x72dpi), epswlo (9-pin 120x144dpi), epsmed
  118. rem    (9-pin 240x144dpi), epson (9-pin 240x216dpi), lqmed (24-pin
  119. rem    360x180dpi) and DJFiveTwenty (600x300dpi), as well as their
  120. rem    landscape versions.
  121.  
  122. if %5==%6 goto SQUARE_PIXELS
  123. set PK_MAG=%2
  124. if %6==300    set PK_DEV=DJFiveTwenty
  125. if %6==72    set PK_DEV=epsdrft
  126. if %6==216    set PK_DEV=epson
  127. if %6==180    set PK_DEV=lqmed
  128. if %6==144    goto FX_LOMED
  129. if %5==300    set PK_DEV=DJFiveTwentyl
  130. if %5==72    set PK_DEV=epsdrftl
  131. if %5==216    set PK_DEV=epsonl
  132. if %5==180    set PK_DEV=lqmedl
  133. if %5==144    goto LAND_FX_LOMED
  134. goto DO_IT
  135. :FX_LOMED
  136. if %5==120    set PK_DEV=epswlo
  137. if %5==240    set PK_DEV=epsmed
  138. goto DO_IT
  139. :LAND_FX_LOMED
  140. if %6==120    set PK_DEV=epswlol
  141. if %6==240    set PK_DEV=epsmedl
  142. goto DO_IT
  143.  
  144.  
  145. rem    Devices with square pixels. The current code supports the resolutions
  146. rem    used by the Beebe drivers for the screen, 300dpi and 400dpi laser
  147. rem    and inkjet printers, 600dpi laserjets, 24-pin printers at 180x180
  148. rem    and 360x360dpi.
  149.  
  150. :SQUARE_PIXELS
  151. if %5==180    set PK_DEV=lqlores
  152. if %5==360    set PK_DEV=lqhires
  153. if %5==300    set PK_DEV=hplaser
  154. if %5==400    set PK_DEV=nexthi
  155. if %5==600    set PK_DEV=ljfour
  156. if +%PK_DEV%==+ goto OTHER_SQ
  157. set PK_MAG=%2
  158. goto DO_IT
  159. :OTHER_SQ
  160. if %3==58    set PK_MAG=-9
  161. if %3==64    set PK_MAG=-8.5
  162. if %3==70    set PK_MAG=-8
  163. if %3==76    set PK_MAG=-7.5
  164. if %3==84    set PK_MAG=-7
  165. if %3==92    set PK_MAG=-6.5
  166. if %3==100    set PK_MAG=-6
  167. if %3==110    set PK_MAG=-5.5
  168. if %3==121    set PK_MAG=-5
  169. if %3==132    set PK_MAG=-4.5
  170. if %3==145    set PK_MAG=-4
  171. if %3==158    set PK_MAG=-3.5
  172. if %3==174    set PK_MAG=-3
  173. if %3==190    set PK_MAG=-2.5
  174. if %3==208    set PK_MAG=-2
  175. if %3==228    set PK_MAG=-1.5
  176. if %3==250    set PK_MAG=-1
  177. if %3==274    set PK_MAG=-0.5
  178. if %3==300    set PK_MAG=0
  179. if %3==329    set PK_MAG=0.5
  180. if %3==360    set PK_MAG=1
  181. if %3==394    set PK_MAG=1.5
  182. if %3==432    set PK_MAG=2
  183. if %3==473    set PK_MAG=2.5
  184. if %3==518    set PK_MAG=3
  185. if %3==568    set PK_MAG=3.5
  186. if %3==622    set PK_MAG=4
  187. if %3==681    set PK_MAG=4.5
  188. if %3==746    set PK_MAG=5
  189. if %3==818    set PK_MAG=5.5
  190. if %3==896    set PK_MAG=6
  191. if %3==981    set PK_MAG=6.5
  192. if %3==1075    set PK_MAG=7
  193. if %3==1178    set PK_MAG=7.5
  194. if %3==1290    set PK_MAG=8
  195. if NOT +%PK_MAG%==+ set PK_DEV=hplaser
  196.  
  197. :DO_IT
  198. if +%PK_DEV%==+    goto UNKNOWN
  199. echo on
  200. %MF% \scrollmode;mode:=%PK_DEV%;mag:=magstep(%PK_MAG%);input %1
  201. @echo off
  202. if errorlevel 1 goto ERROR_EXIT
  203.  
  204. rem    Find out if the directories already exist to avoid
  205. rem    any warning messages
  206. if not exist %PK_BASE%\nul md %PK_BASE%
  207. if not exist %PK_DIR%\nul  md %PK_DIR%
  208.  
  209. rem    This stupid trick is necessary because some versions of Metafont
  210. rem    use an extension of NNNgf (where NNN is the hor. resolution) and
  211. rem    truncate it to 3 chars. while other versions use just NNN which
  212. rem    they also truncate to 3 chars.
  213. set GF_EXT=%3
  214. if exist %1.%9 set GF_EXT=%9
  215.  
  216. gftopk %1.%GF_EXT%  %PK_DIR%\%1.pk
  217. del %1.%GF_EXT%
  218. del %1.log
  219.  
  220. rem    If you want to copy the TFM file to an appropriate directory,
  221. rem    here is the place to do it.
  222. del %1.tfm
  223. goto GETOUT
  224.  
  225. :UNKNOWN
  226. echo I don't know the metafont mode for this device. Please
  227. echo add this information to the file %0
  228.  
  229. :ERROR_EXIT
  230. rem    The next line creates a small file in the TEMP directory. This
  231. rem    signals the error to the "genall.bat" file, so it doesn't call
  232. rem    dviwin again when running under NT.
  233. echo ERROR > %TEMP%\error$_$
  234. pause
  235.  
  236. :GETOUT
  237.